import requests
#如果提示requests出错，可能需要安装request CMD运行 pip install requests
def get_proxy(headers):
    proxy_url = 'http://http.9vps.com/getip.asp?username=andy9527&pwd=2192c496183c0655a8174fdf2640a347&geshi=1&fenge=1&fengefu=&getnum=500'
    aaa=requests.get(proxy_url, headers=headers).text
    #print(aaa)
    proxy_host = aaa.strip()
    #proxy_host='1.193.175.60:10808'
    print("proxy_host: ", proxy_host)
    proxy = {
        'http': proxy_host,
        # 'https': proxy_host,
    }
    print("proxy: ", proxy)
    return proxy


if __name__ == '__main__':
    url = 'https://nb.zu.anjuke.com/fangyuan/yinzhou/p4/'
    # url = 'www.baidu.com'
    # url = 'http://202020.ip138.com'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36'
    }
    proxy = get_proxy(headers)
    print(proxy)
    proxy = {
        'http': "112.85.58.6:31011",
    #     # 'https': "112.85.58.6:31011",
    }

    r = requests.get(url, headers=headers, proxies=proxy, verify=False)
    print(r.text)

    
    url = 'https://nb.zu.anjuke.com/fangyuan/yinzhou/p1/'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36'
    }

    r = requests.get(url, headers=headers, proxies=proxy, verify=False)
    print(r.text)
    print(proxy)
